<template>
    <div>
        <el-page-header @back="goBack" content="权限管理"></el-page-header>
        <div style="margin:20px">
            <span style="margin-right:20px">
                *机构名称: {{this.listData.title}}
            </span>
            <span>
                管理员账号：{{this.listData.account_number}}
            </span>
        </div>
        <el-radio-group v-model="tabPosition" style="margin-bottom: 30px;">
            <el-radio-button label="ones" disabled>测评系统</el-radio-button>
            <el-radio-button label="twos">可视化大屏</el-radio-button>
            <el-radio-button label="threes" disabled>生涯管理系统</el-radio-button>
            <el-radio-button label="fours" disabled>预约系统</el-radio-button>
        </el-radio-group>
        <div v-show="tabPosition=='ones'">
            测评系统
        </div>
        <div v-show="tabPosition=='twos'">
            可视化大屏
        </div>
        <div v-show="tabPosition=='threes'">
            生涯管理系统
        </div>
        <div v-show="tabPosition=='fours'">
            预约系统
        </div>
        <el-card shadow="never" style="margin:15px 0px">
            <el-checkbox v-model="checked">开启</el-checkbox>
        </el-card>
        <el-button type="primary" size="small" @click="submit_fn">保存</el-button>
    </div>
</template>
<script>
import { UpdateJurisdiction, ModifyMechanismPermissio } from '@/common/api'
export default {
  data () {
    return {
      tabPosition: 'twos',
      checked: true,
      member_id: this.$route.query.member_id,
      listData: {
        title: '',
        account_number: ''
      }
    }
  },
  created () {
    this.selectData()
  },
  methods: {
    selectData () {
      UpdateJurisdiction({member_id: this.member_id}).then(res => {
        this.listData = res.data.data
        this.checked = res.data.data.func_auth.is_open_mechanism
      })
    },
    goBack () {
      this.$router.push('/users_management')
    },
    submit_fn () {
      let datas = {
        member_id: this.member_id,
        is_open_mechanism: this.checked
      }
      ModifyMechanismPermissio(datas).then(res => {
        if (res.data.status === 1) {
          this.selectData()
          this.$message({
            message: res.data.msg,
            type: 'success'
          })
        } else {
          this.$message.error(res.data.msg)
        }
      }).catch(err => {
        this.$message.error(err.data.msg)
      })
    }
  }
}
</script>
